package ru.onlinestore.mobile.ui.authentication.registration

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import ru.onlinestore.mobile.ui.components.ButtonCompose
import ru.onlinestore.mobile.ui.components.ButtonText
import ru.onlinestore.mobile.ui.components.textInput

@Composable
@Preview(
    showBackground = true,
    device = "id:Xiaomi POCO M5s"
)
private fun RegistrationScreenPreview() = RegistrationScreen()

private val username = mutableStateOf("")
private val password = mutableStateOf("")
private val repeatPassword = mutableStateOf("")
private val isNotEmptyInputForm: Boolean =
    username.value.isNotEmpty() && password.value.isNotEmpty() && repeatPassword.value.isNotEmpty()

@Composable
fun RegistrationScreen() {
    Column(
        modifier = Modifier
            .fillMaxSize()
            .padding(24.dp),
        content = {
            username.value = textInput(
                label = "Имя пользователя",
                keyboardType = KeyboardType.Text
            )
            
            password.value = textInput(
                label = "Пароль",
                keyboardType = KeyboardType.Text
            )

            repeatPassword.value = textInput(
                label = "Повторите пароль",
                keyboardType = KeyboardType.Text
            )

            ButtonText(
                text = "Уже есть аккаунт?",
                onClick = {

                }
            )

            ButtonCompose(
                title = "Зарегистрироваться",
                onClick = {

                },
                fontSize = 17.sp,
                enabled = username.value.isNotEmpty() && password.value.isNotEmpty() && repeatPassword.value.isNotEmpty()
            )
        },
        verticalArrangement = Arrangement.spacedBy(
            space = 12.dp,
            alignment = Alignment.CenterVertically
        ),
        horizontalAlignment = Alignment.CenterHorizontally
    )
}
